#include <iostream>
#include <cstdio>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    char *const argv[] = {
      (char*)"ls",
      (char*)"--color",
      (char*)"-a",
      (char*)"-l",
      nullptr
    };
    (void)argv;
    
    execvp("ls",argv); 
    //execv("/user/bin/ls",argv);
    //execlp("ls","ls","--color","-a","-l",nullptr); 
    exit(1);
  }

  pid_t rid = waitpid(id,nullptr,0);
  if(rid > 0)
  {
    printf("等待子进程成功!\n");
  }
  return 0;
}
